﻿using ConfExpert.Forms.Base;
using DevTeam;
using System;

namespace ConfExpert.Forms.Ithalat
{
    public partial class BarsanDosyaEdit : XForm
    {
        string REFERANS;
        public BarsanDosyaEdit(string REFERANS)
        {
            InitializeComponent();
            this.REFERANS = REFERANS;
        }

        private void BarsanDosyaEdit_Load(object sender, EventArgs e)
        {
            gridView2.Init("GetFaturaBilgiByReferans", REFERANS);

            gridView2.Columns["Miktar"].ColumnEdit =
                gridView2.Columns["FaturaTutar"].ColumnEdit = new DevExpress.XtraEditors.Repository.RepositoryItemCalcEdit();
            gridView2.FormatAsNumber(2, "Miktar", "FaturaTutar");
            gridView2.AddSummary("Miktar", "FaturaTutar");
            gridView2.MakeColumnInvisible("FaturaId");
            //gridView2.EnableRowDelete();
            //gridView2.EnableNewRow();    //FaturaId nin ne olacağına SP karar veriyordu, bu tehlikeli!
            gridView2.DataTable().SetPK("FaturaId"); 
            btnKaydet.ItemClick += btnKaydet_ItemClick;
            gridView2.BestFitColumns();
        }

        void btnKaydet_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gridView2.EndEditing();
            string xml = gridView2.SerializeChanges();
            ExecuteNonQuery("UpdFaturaBilgi", xml);
            //gridView2.Update("Tarih,FaturaId,FaturaNo,FaturaTutar,FaturaDoviz,Miktar", "UNS_FATURABILGI_ROW");
            gridView2.BestFitColumns();
        }
    }
}
